﻿using System;
using System.ComponentModel;
using FrameWork.Data.Mapping;
using MongoDB.Bson.Serialization.Attributes;
using SqlSugar;

namespace FrameWork.Data.ViewObject
{
    /// <summary>
    /// 测试记录表
    /// </summary>
    [SugarTable("TestRecordData")]
    public class TestRecordData : ModelBase
    {
        private string _Uuid = string.Empty;
        /// <summary>
        /// 唯一编码
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 64, ColumnDescription = "uuId")]
        [Description("唯一编码")]
        public string Uuid
        {
            get { return _Uuid; }
            set { _Uuid = value; OnPropertyChanged(nameof(Uuid)); }
        }
        private string _TestBarcode = string.Empty;
        /// <summary>
        /// 测试条码
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 64, ColumnDescription = "测试条码")]
        [Description("测试条码")]
        public string TestBarcode
        {
            get { return _TestBarcode; }
            set { _TestBarcode = value; OnPropertyChanged(nameof(TestBarcode)); }
        }
        private string _BatteryNo = string.Empty;
        /// <summary>
        /// 测试条码
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 64, ColumnDescription = "虚拟电池编号")]
        [Description("虚拟电池编号")]
        public string BatteryNo
        {
            get { return _BatteryNo; }
            set { _BatteryNo = value; OnPropertyChanged(nameof(BatteryNo)); }
        }
        private long _TestTemplateId;
        /// <summary>
        /// 测试模版数据
        /// </summary>
        [SugarColumn(ColumnDescription = "测试模版编码")]
        [Description("测试模版编码")]
        public long TestTemplateId
        {
            get { return _TestTemplateId; }
            set { _TestTemplateId = value; OnPropertyChanged(nameof(TestTemplateId)); }
        }
        private int _DeviceBox;
        /// <summary>
        /// 设备箱号
        /// </summary>
        [SugarColumn(ColumnDescription = "设备箱号")]
        [Description("设备箱号")]
        public int DeviceBox
        {
            get { return _DeviceBox; }
            set { _DeviceBox = value; OnPropertyChanged(nameof(DeviceBox)); }
        }
        private int _DeviceChannel;
        /// <summary>
        /// 设备通道号 用来做打印
        /// </summary>
        [SugarColumn(ColumnDescription = "设备通道号")]
        [Description("设备通道号")]
        public int DeviceChannel
        {
            get { return _DeviceChannel; }
            set { _DeviceChannel = value; OnPropertyChanged(nameof(DeviceChannel)); }
        }

        private DateTime _TestStartTime;
        /// <summary>
        /// 测试开始时间
        /// </summary>
        [SugarColumn(ColumnDescription = "测试开始时间")]
        [Description("测试开始时间")]
        [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
        public DateTime TestStartTime
        {
            get { return _TestStartTime; }
            set { _TestStartTime = value; OnPropertyChanged(nameof(TestStartTime)); }
        }
        private DateTime _TestEndTime;
        /// <summary>
        /// 测试结束时间
        /// </summary>
        [SugarColumn(ColumnDescription = "测试结束时间")]
        [Description("测试结束时间")]
        [BsonDateTimeOptions(Kind = DateTimeKind.Local)]
        public DateTime TestEndTime
        {
            get { return _TestEndTime; }
            set { _TestEndTime = value; OnPropertyChanged(nameof(TestEndTime)); }
        }
        private string _DeviceHost = string.Empty;
        /// <summary>
        /// 设备IP地址
        /// </summary>
        [SugarColumn(Length = 20, ColumnDescription = "设备IP地址")]
        [Description("设备IP地址")]
        public string DeviceHost
        {
            get { return _DeviceHost; }
            set { _DeviceHost = value; OnPropertyChanged(nameof(DeviceHost)); }
        }
     
        private string _LoopDataTable = string.Empty;
        /// <summary>
        /// 循环表名(表名)
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 100, ColumnDescription = "循环表名")]
        [Description("循环表名")]
        public string LoopDataTable
        {
            get { return _LoopDataTable; }
            set { _LoopDataTable = value; OnPropertyChanged(nameof(LoopDataTable)); }
        }
        private string _StepDataTable = string.Empty;
        /// <summary>
        /// 工步表名(表名)
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 100, ColumnDescription = "工步表名")]
        [Description("工步表名")]
        public string StepDataTable
        {
            get { return _StepDataTable; }
            set { _StepDataTable = value; OnPropertyChanged(nameof(StepDataTable)); }
        }
        private string _DetailDataTable = string.Empty;
        /// <summary>
        /// 测试详细记录表(表名)
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 100, ColumnDescription = "详细记录")]
        [Description("详细记录")]
        public string DetailDataTable
        {
            get { return _DetailDataTable; }
            set { _DetailDataTable = value; OnPropertyChanged(nameof(DetailDataTable)); }
        }
        private string _EventDataTable = string.Empty;
        /// <summary>
        /// 事件记录表
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 100, ColumnDescription = "事件表")]
        [Description("事件表")]
        public string EventDataTable
        {
            get { return _EventDataTable; }
            set { _EventDataTable = value; OnPropertyChanged(nameof(EventDataTable)); }
        }
        private string _TestEndEvent = string.Empty;
        /// <summary>
        /// 测试事件
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "测试事件")]
        [Description("测试事件")]
        public string TestEndEvent
        {
            get { return _TestEndEvent; }
            set { _TestEndEvent = value; OnPropertyChanged(nameof(TestEndEvent)); }
        }
        private string _DefaultFileName = string.Empty;
        /// <summary>
        /// 数据明细记录表 (表名)
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 100, ColumnDescription = "默认导出文件名")]
        [Description("默认导出文件名")]
        public string DefaultFileName
        {
            get { return _DefaultFileName; }
            set { _DefaultFileName = value; OnPropertyChanged(nameof(DefaultFileName)); }
        }
        private string _TestUser = string.Empty;
        /// <summary>
        /// 测试员
        /// </summary>
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "测试员")]
        [Description("测试员")]
        public string TestUser
        {
            get { return _TestUser; }
            set { _TestUser = value; OnPropertyChanged(nameof(TestUser)); }
        }
        /// <summary>
        /// 累积容量
        /// </summary>
        [SugarColumn(IsNullable = true, ColumnDescription = "累积工步号")]
        [Description("累积工步号")]
        public int StepAccIndex { get; set; }
        /// <summary>
        /// 累积容量
        /// </summary>
        [SugarColumn(IsNullable = true, DecimalDigits = 6, ColumnDescription = "累积容量")]
        [Description("累积容量")]
        public double? AccCapacity { get; set; }
        /// <summary>
        /// 充电累积容量
        /// </summary>
        [SugarColumn(IsNullable = true, DecimalDigits = 6, ColumnDescription = "充电累积容量")]
        [Description("充电累积容量")]
        public double? ChargeAccCapacity { get; set; }
        /// <summary>
        /// 放电累积容量
        /// </summary>
        [SugarColumn(IsNullable = true, DecimalDigits = 6, ColumnDescription = "放电累积容量")]
        [Description("放电累积容量")]
        public double? DischargeAccCapacity { get; set; }
        /// <summary>
        /// 累积能量
        /// </summary>
        [SugarColumn(IsNullable = true, DecimalDigits = 6, ColumnDescription = "累积能量")]
        [Description("累积能量")]
        public double? AccEnergy { get; set; }
        /// <summary>
        /// 充电累积能量
        /// </summary>
        [SugarColumn(IsNullable = true, DecimalDigits = 6, ColumnDescription = "充电累积能量")]
        [Description("充电累积能量")]
        public double? ChargeAccEnergy { get; set; }
        /// <summary>
        /// 放电累积能量
        /// </summary>
        [SugarColumn(IsNullable = true, DecimalDigits = 6, ColumnDescription = "放电累积能量")]
        [Description("放电累积能量")]
        public double? DischargeAccEnergy { get; set; }

        #region 充放电循环号
        /// <summary>
        /// 充放电循环号
        /// </summary>
        [SugarColumn(ColumnDescription = "充放电循环号")]
        [Description("充放电循环号")]
        public int ChargeDischargeLoopIndex { get; set; }
        /// <summary>
        /// 是否出现了‘放电类型’，作为‘充放电循环号’变动的判断条件
        /// </summary>
        [SugarColumn(ColumnDescription = "是否出现了放电类型")]
        [Description("是否出现了放电类型")]
        public bool IsDischargeTypePresent { get; set; }
        [Description("数据索引位置")]
        public int DataRecordIndex { get; set; }
        #endregion


        /// <summary>
        /// 是否长传完成
        /// </summary>
        [SugarColumn(IsNullable = true, DecimalDigits = 6, ColumnDescription = "是否长传完成")]
        [Description("是否长传完成")]

        //1充电 2放电类型
        public bool Completed { get; set; }
        [SugarColumn(IsNullable = true, DecimalDigits = 6, ColumnDescription = "上一工步的类型")]
        [Description("上一工步的类型")]
        public int LastChargeDischargeIndex { get; set; }
     
        [SugarColumn(IsNullable = true, DecimalDigits = 6, ColumnDescription = "是否修改充放电工步")]
        [Description("是否修改充放电工步")]
        public bool ChangedChargeDischargeType { get; set; }
        [SugarColumn(IsNullable = true, DecimalDigits = 6, ColumnDescription = "上次充电结束标记 1:充电 0:放电，其他0")]
        [Description("上次充电结束标记 1:充电 0:放电，其他0")]
        public int  LastLoopEndFlag { get; set; }
    }
}